package com.cnipr.patent;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

public class PatentDetailActivity extends Activity {
	
	private String m_an;
	private String m_pnm;
	private Patent m_patent;
	private DataAccessHandler m_handler;
	private DataAccessThread m_dataAccessThread;
	
	private class DataAccessHandler extends Handler {
		@Override 
		public void handleMessage(Message msg) {
			switch(msg.what) {
			case 0: 
				UpdateUI();
				break;
			default:
				break;
			}
			super.handleMessage(msg);
		}
	}
	
	private class DataAccessThread extends Thread {

		@Override
		public void run() {
		
			PatentDataAccess dataAccess = new PatentDataAccess();
			try {
				m_patent = dataAccess.getPatent(m_an, m_pnm);
				Message msg = new Message();
				msg.what = 0;
				m_handler.sendMessage(msg);
			}
			catch(Exception e) {
				Message msg = new Message();
				msg.what = -1;
				m_handler.sendMessage(msg);
			}
		}
	}
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.patent_detail_layout);
		
		getExtras();
		
		m_handler = new DataAccessHandler();
		 m_dataAccessThread = new DataAccessThread();
		 m_dataAccessThread.start();
	}
	
	private void getExtras() {
		Intent intent = getIntent();
		m_an = intent.getExtras().getString("an");
		m_pnm = intent.getExtras().getString("pnm");
	}
	
	private void UpdateUI() {
		
	}
	
	@Override 
	protected void onDestroy () {
		m_dataAccessThread.stop();
	}
	
	
	
}


